package com.mall.shopping.dto;

import com.mall.commons.doc.ItemDoc;
import lombok.Data;

import java.io.Serializable;
import java.math.BigDecimal;

/**
 *  cskaoyan
 */
@Data
public class ProductDto implements Serializable {

    private static final long serialVersionUID = 2763986506997467400L;
    private Long productId;// id

    private BigDecimal salePrice;// price

    private String productName;// title

    private String subTitle;// sell_point

    private String picUrl;// image[0]

    public ProductDto() {
    }

    public ProductDto(ItemDoc itemDoc) {
        this.productId = itemDoc.getId();
        this.salePrice = BigDecimal.valueOf(itemDoc.getPrice());
        this.productName = itemDoc.getTitle();
        this.subTitle = itemDoc.getSellPoint();
        if (itemDoc.getImage().contains(",")) {
            this.picUrl = itemDoc.getImage().split(",")[0];
        } else {
            this.picUrl = itemDoc.getImage();
        }
    }
}
